<template>
  <view class="newbox">
    <view class="pic">
      <image :src="item.picurl" mode="scaleToFill"></image>
    </view>
    <view class="text">
      <view class="title">{{item.title}}</view>
      <view class="info" v-if="type === 0">
        <text class="author" style="padding-right: 20rpx;">{{item.author}}</text>
        <text>{{item.hits}}浏览</text>
      </view>
      <view class="info" v-else>
        <text>{{item.lookTime}}</text>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    name: "newsbox",
    props: {
      type: {
        type: Number
      },
      item: {
        type: Object,
        default () {
          return {
            title: "默认标题",
            hits: 996,
            picurl: "../../static/logo.png",
            lookTime: null
          }
        }
      }
    },
    data() {
      return {}
    },
    methods: {
    }
  }
</script>

<style lang="scss" scoped>
  .newbox {
    display: flex;

    .pic {
      width: 230rpx;
      height: 160rpx;

      image {
        width: 100%;
        height: 100%;
      }
    }

    .text {
      flex: 1;
      padding-left: 20rpx;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .title {
        color: #333;
        font-size: 38rpx;
        // 超过两行显示省略号
        text-overflow: -o-ellipsis-lastline;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;

      }

      .info {
        font-size: 28rpx;
        color: #999;

        .author {
          padding-right: 30rpx;
        }
      }
    }
  }
</style>
